package com.dean.exception;

/**
 * dean 自定义异常 处理异常信息
 * @author Administrator
 *
 */
public class DeanException extends Exception{

    private static final long serialVersionUID = 520131420111108L;
	/**
	 * 错误状态码
	 */
	private Integer code;
	/**
	 * 错误信息
	 */
	private String msg;

	public static DeanException throwException(Integer code) throws DeanException {
		throw  new DeanException(code);
	}

	public static DeanException throwException(String msg) throws DeanException {
		throw new DeanException(msg);

	}

	public static DeanException throwException(Integer code, String msg) throws DeanException {
		throw new DeanException(code,msg);
	}

	/**
	 * 用于国际化 通过handler 提取具体的错误信息 只需要传入错误码
	 * @param code
	 */
	public DeanException(Integer code) {
		super(code+"");
		this.code = code;
	}

	/**
	 * 建议处理错误信息  提示对应的错误信息
	 * @param msg
	 */
	public DeanException(String msg) {
		super(msg);
		this.msg = msg;
	}

	public DeanException(Integer code,String msg) {
		super(msg);
		this.code = code;
		this.msg = msg;
	}
	
	public DeanException(Integer code,String msg,Throwable cause) {
		super(msg,cause);
		this.code = code;
	}

	public Integer getCode(){
		return this.code;
	}

	public String getMsg(){
		return this.msg;
	}

}
